
MAPPATH =../../MAP_LIB
NAME    =job.exe
MN      =model_new
MPIRUN  =
FC      =mpif90
OPT     =-O2 -warn -traceback -vec-report0 -module $(MAPPATH)

FILES   =\
$(MAPPATH)/parameters.f90 \
$(MAPPATH)/block_define.f90 \
$(MAPPATH)/interfaces.f90 \
$(MAPPATH)/main.f90 \
$(MAPPATH)/read_parameters.f90 \
$(MAPPATH)/amr.f90 \
$(MAPPATH)/regrid.f90 \
$(MAPPATH)/integrate.f90 \
$(MAPPATH)/block_generate.f90 \
$(MAPPATH)/block_destroy.f90 \
$(MAPPATH)/block_boundary.f90 \
$(MAPPATH)/tvd_mmc.f90 \
$(MAPPATH)/tvd_lf.f90 \
$(MAPPATH)/ucs.f90 \
$(MAPPATH)/weno.f90 \
$(MAPPATH)/weno_l.f90 \
$(MAPPATH)/flux.f90 \
$(MAPPATH)/flux_split.f90 \
$(MAPPATH)/hlld.f90 \
$(MAPPATH)/hllc.f90 \
$(MAPPATH)/roe.f90 \
$(MAPPATH)/eigenspace.f90 \
$(MAPPATH)/block_output.f90 \
$(MAPPATH)/bnd_free_x.f90 \
$(MAPPATH)/block_info.f90 \
model_initial.f90

FILES_D =$(MAPPATH)/data_manage.f90 \
$(MAPPATH)/write_mapvis.f90 \
$(MAPPATH)/extremum_calculate.f90 \
$(MAPPATH)/write_vtu_header.f90 \
$(MAPPATH)/write_vtu_data.f90 \
$(MAPPATH)/write_vtk_unstructured.f90 \
$(MAPPATH)/data_collect.f90 

OBJS    =$(FILES:.f90=.o)

$(NAME):$(OBJS)
	$(FC) $(OPT) -o $(NAME) $(OBJS)
	@echo
	@echo Compile completed!

%.o:%.f90
	$(FC) $(OPT) -c -o $@ $<

../$(BNDLIB):
	cd $(BDLIBPATH);make FC=$(FC) OPT="$(OPT)"

run:$(NAME)
	$(MPIRUN) $(PWD)/$(NAME)

rddt:
	$(FC) $(OPT) -o rddt.exe $(FILES_D)
	mpiexec -n 1 ./rddt.exe

new:
	mkdir -p ../$(MN)
	cp *.f90 parameters Makefile *.pro ../$(MN)

clean:
	rm -f $(OBJS) $(NAME) a.out rddt.exe *genmod* *~ *\* input *.mod fort.11
	rm -rf `ls -d */ 2> /dev/null`
	cd $(MAPPATH); rm -f *genmod* *~ *\* input *.mod
	@echo
	@echo Clean completed!

cleanall:
	rm -f $(OBJS) $(NAME) a.out rddt.exe *genmod* *~ *\* input *.mod *.include fort.11
	rm -rf `ls -d */ 2> /dev/null`
	cd $(MAPPATH); rm -f *genmod* *~ *\* input *.mod
	rm -f ./data/*
	@echo
	@echo Cleanall completed
	



